Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@smithy/middleware-content-length

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/middleware-content-length

[![NPM version](https://img.shields.io/npm/v/@smithy/middleware-content-length/latest.svg)](https://www.npmjs.com/package/@smithy/middleware-content-length) [![NPM downloads](https://img.shields.io/npm/dm/@smithy/middleware-content-length.svg)](https://ww

  • 2.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13M
decreased by-16.56%
Maintainers
2
Weekly downloads
 
Created

What is @smithy/middleware-content-length?

@smithy/middleware-content-length is a middleware package for the Smithy client framework. It is used to automatically calculate and set the Content-Length header for HTTP requests. This is particularly useful when dealing with payloads where the size needs to be explicitly defined.

What are @smithy/middleware-content-length's main functionalities?

Automatic Content-Length Calculation

This feature automatically calculates the Content-Length of the request body and sets it in the HTTP headers. This is useful for ensuring that the server knows the size of the incoming request payload.

const { ContentLengthMiddleware } = require('@smithy/middleware-content-length');
const { HttpRequest } = require('@smithy/protocol-http');

const request = new HttpRequest({
  hostname: 'example.com',
  method: 'POST',
  body: JSON.stringify({ key: 'value' })
});

const middleware = ContentLengthMiddleware();
const handler = middleware((next) => async (args) => {
  return next(args);
});

handler({ request }).then((response) => {
  console.log(response.request.headers['Content-Length']); // Outputs the calculated Content-Length
});

Other packages similar to @smithy/middleware-content-length

FAQs

Package last updated on 14 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc